<meta charset="utf-8">
<?php
session_start();
require_once("mysql.php"); 
/*mysql_connect("localhost","root","1");
mysql_select_db("my_db");  */ 
$username=$_POST['username'];  
$password=$_POST['password']; 
if($username == "")  
{  
   
     echo "<script type='text/javascript'>alert('请填写用户名');location='login.php';  
            </script>";  
      
  
}  
else if($password == "")  
      {  
         echo"<script type='text/javascript'>alert('请填写密码');location='login.php';</script>";  
      }  
      else  
      {   
          $sql = "select * from work where username='$username' AND password='$password'";  
          $result = mysql_query($sql);
          $count=mysql_num_rows($result);/*
          echo $count;*/
          if($count>0)
          {
              echo"<script type='text/javascript'>alert('登陆成功');location='huanying.php';</script>"; 
              $_SESSION['username']=$username;
              break;
          }
          else
          {
              echo"<script type='text/javascript'>alert('用户名或密码错误');location='login.php';</script>"; 
          }
        /*  $num=count($colum); 
          while($i<$num)
          {
              if(($colum[$i]['username'] == $username) && ($colum[$i]['password'] == $password)) 
              {

                  echo"<script type='text/javascript'>alert('登陆成功');location='huanying.php';</script>"; 
                                    break;
              }  
              $i++;
          }
          if($i>=$num)
          {
             echo"<script type='text/javascript'>alert('用户名或密码错误');location='login.php';</script>"; 
          }*/
      } 
?>
